package com.zbiti.anvil.basic.module.business.autoconfigure;

import com.zbiti.anvil.basic.module.business.api.service.ISamplesLeaveService;
import com.zbiti.anvil.basic.module.business.service.event.SamplesLeaveEventBinder;
import com.zbiti.anvil.basic.module.business.service.mapper.SamplesLeaveMapper;
import com.zbiti.anvil.basic.module.business.service.service.impl.SamplesLeaveServiceImpl;
import com.zbiti.anvil.wf.api.service.IWfService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 业务系统自动装配
 *
 * @author Fanyc
 * @date 2021-09-08 11:06
 */
@Configuration
public class BusinessConfiguration {

    /**
     * 流程服务
     */
    @Autowired(required = false)
    private IWfService wfService;

    /**
     * 示例：请假申请流程服务
     *
     * @param samplesLeaveMapper 示例：请假申请流程Mapper
     * @return 服务对象
     */
    @Bean(name = "samplesLeaveServiceImpl")
    public ISamplesLeaveService samplesLeaveServiceImpl(SamplesLeaveMapper samplesLeaveMapper) {
        return new SamplesLeaveServiceImpl(samplesLeaveMapper, wfService);
    }

    /**
     * 请假流程审批事件监听
     *
     * @param samplesLeaveService 请假申请流程服务
     * @return 监听器对象
     */
    @Bean(name = "samplesLeaveEventBinder")
    public SamplesLeaveEventBinder samplesLeaveEventBinder(ISamplesLeaveService samplesLeaveService) {
        return new SamplesLeaveEventBinder(samplesLeaveService.getWfService(), samplesLeaveService);
    }
}
